/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __TIMER_H__
#define __TIMER_H__

#pragma once

#include "common/Singleton.h"

/**
 * \ingroup CoreEngine
 *
 * The Timer class.<br>
 * Handles high precision (!!!) timing of the application.<br>
 * The getTime() command returns the number of miliseconds since the timer was last reset.<br>
 * The getTimeDiff() returns the number of seconds since the last call.<br>
 * Usage: coreGetTimer()->getTime()
 *
 * \date 03-28-2007
 *
 * \author juckel
 *
 * \todo Check for high precision
 *
 */
class DLL_EXPORT Timer
//	: public Singleton<Timer>
{
public:
	void Destroy();

	/// Resets the Timer to 0
	void reset();

	/// Pauses the Timer
	void pause();

	/// Unpauses the Timer
	void unpause();

	/// Indicates if the Timer is paused
	const bool isPaused() const;

	/// Returns the time in milliseconds since the timer object was created or since the last reset
	double getTime();

	/// Return the number of seconds since the last call of getTimeDiff()
	double getTimeDiff();

	double getLastTimeDiff();

	/// Returns the current frames per second
	int getFPS();

	Timer(void);
	virtual ~Timer(void);

private:
	double dDiff;
	bool          bPaused;
	LARGE_INTEGER lStartTime;
	LARGE_INTEGER lPauseTime;
	LARGE_INTEGER lLastTime;
	LARGE_INTEGER lNow;
	LARGE_INTEGER lDiff;
	
	LARGE_INTEGER lFreq;
};


/**
 *  Returns the timer object for updating the scene and retreiving time information
 *  \returns The timer object
 */
DLL_EXPORT 
Timer* coreGetTimer();

DLL_EXPORT 
bool coreInitTimer();



#endif
